<template>
  <div v-show="show" class="pagination-wrapper">
    <el-pagination
      ref="pagination"
      :current-page.sync="currentPage"
      :page-size="pageSize"
      layout="total, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>
<script>
export default {
  props: {
    list: {
      type: Array,
      default: () => []
    },
    total: {
      type: Number,
      default: 1
    },
    pageSize: {
      type: Number,
      default: 15
    },
    curPage: {
      type: Number,
      default: 1
    }
  },
  data() {
    return {
      show: false,
      currentPage: 1
    }
  },
  watch: {
    curPage(newVal) {
      this.currentPage = newVal
    },
    list() {
      this.show = true
    }
  },
  mounted() {
    setTimeout(() => {
      this.show = true
    }, 600)
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.$emit('nextPage', val)
    }
  }
}
</script>
<style lang="scss" scoped>

</style>
